<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<div id="log"></div>
<script>
test(() => assert_selection(
    '<div contenteditable>foo<br><div>|bar</div></div>',
    'insertParagraph',
    '<div contenteditable>foo<br><div><br></div><div>|bar</div></div>'),
    'insert a paragraph separator after BR and before character');

test(() => assert_selection(
    '<div contenteditable>foo<div>|bar</div></div>',
    'insertParagraph',
    '<div contenteditable>foo<div><br></div><div>|bar</div></div>'),
    'insert a paragraph separator before character');

// A Test for a bug in the paragraph separator insertion code that would add an
// extra newline when inserting a paragraph separator at the end of a paragraph
// in text that preserves newlines. Also, an extraneous space would be added
// after 'foo'. Only one newline should be added. And there should be no
// extraneous spaces.
//
// It demonstrates a bug: too much padding is left between the new line and the
// end of the paragraph containing 'foo'.
test(() => assert_selection(
    '<div contenteditable><pre>foo\n|bar</pre></div>',
    'insertParagraph',
    '<div contenteditable><pre>foo\n<br></pre><pre>|bar</pre></div>'),
    'insert a paragraph separator in PRE');
</script>

